<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/6/17
 * Time: 17:56
 */

namespace doumiaoduo\ueditor\actions;


use yii\base\Action;
use doumiaoduo\ueditor\UploaderHelper;
use yii\web\Response;

class UploadscrawlAction extends Action
{
    private $_config;

    public function init()
    {
        $this->_config = \Yii::$app->params['ueditor'];
        parent::init();
    }

    public function run()
    {
        \Yii::$app->response->format = Response::FORMAT_JSON;


        $config = array(
            "pathFormat" =>  $this->_config['scrawlPathFormat'],
            "maxSize" => $this->_config['scrawlMaxSize'],
            "oriName" => "scrawl.png"
        );
        $fieldName =$this->_config['scrawlFieldName'];
        $up = new UploaderHelper($fieldName, $config,'base64');
        return $up->getFileInfo();

    }
}

